package com.iweb.dao.impl;

import com.iweb.dao.GradeDao;
import com.iweb.entity.Grade;
import com.iweb.util.DBHelper;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

/**
 * @author WuYongheng
 * @date 2021/11/28
 * @description 年纪dao的实现类
 */
public class GradeDaoImpl implements GradeDao {
    @Override
    public int insert(Grade grade) throws SQLException {
        String sql = "insert into grade values(?,?)";
        Connection conn = null;
        PreparedStatement statement = null;
        try {
            conn = DBHelper.getConnection();
            statement=conn.prepareStatement(sql);
            statement.setInt(1,grade.getGradeId());
            statement.setString(2,grade.getGradeName());
            statement.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            DBHelper.close(statement,conn);
        }
        return 0;
    }

    @Override
    public int delete(Grade gradeId) {
        return 0;
    }

    @Override
    public int update(Grade grade) {
        return 0;
    }

    @Override
    public List<Grade> selectList() {
        return null;
    }
}
